package com.sofar.jwt.service.impl;

import com.sofar.jwt.mapper.TblUserMapper;
import com.sofar.jwt.entity.TblUser;
import com.sofar.jwt.service.TblUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (TblUser)表服务实现类
 *
 * @author makejava
 * @since 2022-08-12 15:43:06
 */
@Service("tblUserService")
public class TblUserServiceImpl implements TblUserService {
    @Resource
    private TblUserMapper tblUserDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public TblUser queryById(Long id) {
        return this.tblUserDao.queryById(id);
    }


    /**
     * 新增数据
     *
     * @param tblUser 实例对象
     * @return 实例对象
     */
    @Override
    public TblUser insert(TblUser tblUser) {
        this.tblUserDao.insert(tblUser);
        return tblUser;
    }

    /**
     * 修改数据
     *
     * @param tblUser 实例对象
     * @return 实例对象
     */
    @Override
    public TblUser update(TblUser tblUser) {
        this.tblUserDao.update(tblUser);
        return this.queryById(tblUser.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.tblUserDao.deleteById(id) > 0;
    }
}
